/**
 * @file lv_appicon.h
 *
 */

#ifndef LV_APPICON_H
#define LV_APPICON_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
 *      INCLUDES
 *********************/
#include "lvgl.h"
#include "../../components/multilingual/lv_multilingual.h"

/*********************
 *      DEFINES
 *********************/

 //lv_appicon_cfg_t->flag
#define LV_APPICON_DIS_NAME           (1 << 7)
#define LV_APPICON_DIS_NAME_FG_COLOR  (1 << 6)
#define LV_APPICON_EN_NAME_BG_COLOR   (1 << 5)
#define LV_APPICON_DIS_STYLE_FOCUSED  (1 << 4) /*can be cancelled when keys are not supported*/
#define LV_APPICON_UNIMAGE_SCALE_MASK 0x07 /*Click on the square`s scale when no image is found*/
/**********************
 *      TYPEDEFS
 **********************/

typedef struct{
    uint32_t id;
    const char * icon_path;  /*Name addition suffix: 1pressed(unsupport), 2focused(unsupport)*/
    const lv_multilingual_t * icon_name;
}lv_appicon_info_t;

typedef struct{
    uint8_t flag;
    uint8_t icon_offset;     /*distance from icon to top*/
    uint8_t name_offset;     /*distance from name to bottom*/
    uint8_t style;           /*reserve style*/
    const lv_style_t *style_pressed; /*NULL is the defuat icon pressed style*/
    const lv_style_t *style_focused; /*NULL is the defuat icon focused style*/
    const lv_font_t * name_font;  /*NULL is the system font*/
    uint32_t name_fg_color;
    uint32_t name_bg_color;
 }lv_appicon_cfg_t;

/**********************
 * GLOBAL PROTOTYPES
 **********************/

/**
 * app icon create, create icons and icon characters, configure click callback
 * @param obj       Container for icons and text
 * @param info      app intrinsic information
 * @param cfg       configuration information in the current system
 * @param event_cb  event call back
 * @return          void
 */
void lv_appicon_create(lv_obj_t * obj, const lv_appicon_info_t *info, const lv_appicon_cfg_t *cfg, lv_event_cb_t event_cb);

/**
 * rebuild icons and names, etc
 * @param obj       Container for icons and text
 * @param info      app intrinsic information
 * @param cfg       configuration information in the current system
 * @param event_cb  event call back
 * @return          void
 */
void lv_appicon_rebuild(lv_obj_t * obj, const lv_appicon_info_t *info, const lv_appicon_cfg_t *cfg, lv_event_cb_t event_cb);

/**
 * focused appicon
 * @param obj       Container for icons and text
 * @return          void
 */
void lv_appicon_add_focused(lv_obj_t * obj);

/**
 * unfocused appicon
 * @param obj       Container for icons and text
 * @return          void
 */
void lv_appicon_remove_focused(lv_obj_t * obj);

/**
 * delete internal elements excluding obj
 * @param obj       Container for icons and text
 * @return          void
 */
void lv_appicon_delete(lv_obj_t * obj);

/**********************
 *      MACROS
 **********************/

#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif /*LV_APPICON_H*/
